import { Component, OnInit } from '@angular/core';
import { MemberService } from '../member.server';
import { Router } from '@angular/router';

@Component({
  selector: 'app-member-center-message-list',
  templateUrl: './member-center-message-list.component.html',
  styleUrls: ['./member-center-message-list.component.scss']
})
export class MemberCenterMessageListComponent implements OnInit {
  private _msgList:Array<any>;
  private _data:Array<any>;
  private _config:Array<any> = [
    {
      name:'类型',
      key:'sendType',
    },{
      name:'时间',
      key:'regDtm'
    },{
      name:'消息',
      key:'title'
    },{
      name:'操作',
      'key':'cz',
      labels:[{
        name:'详情',
        type:'click'
      }]
    }];

  private _page:any={
    pageNo:1,
    pages:1,
    total:10,
    name:'翻页'
  } ;
  
  ngOnInit() {
    this.loadList('消息列表');
  };

  public onClick(e):void{
    this.router.navigate(['/billing', e.data.args], {
      queryParams: {
        type: e.data.sendType,
        back:1
      }
    });

  };
  async loadList(url) {
    let data = await this.memberServer.getAJX(url,this._page);
    this.memberServer.getApiSuccess(data,false) ? this.successListOk(data.data, url) : '';
  };

  public successListOk(data,url):void{
    switch (url) {
      case '消息列表':
        this._page.pageNo = data.pageNo;
        this._page.pages =  data.pages;
        this._data = data.list;
        break;
      case '个人中心[Web前端专用]':
      break;
    };
  };
  
  constructor(
    private memberServer: MemberService,
    private router: Router
  ) { }
}
